{extend name="wap/b2c/base" /} {block name="resources"}
<link rel="stylesheet" type="text/css"
	href="__TEMP__/{$style}/public/css/member_address.css">
{/block} {block name="goodsHead"}
<section class="head">
	<a class="head_back" onclick="window.history.go(-1)"
		href="javascript:void(0)"><i class="icon-back"></i></a>
	<div class="head-title">添加账户</div>
</section>
{/block} {block name="main"}

<form class="form-info">
	<div class="div-item">
		<span>姓名</span> <input type="text" placeholder="请输入真实姓名" id="realname" />
	</div>
	<div class="div-item">
		<span>手机号</span> <input type="text" placeholder="请输入手机号" id="mobile" />
	</div>
	<div class="div-item">
		<span>账号类型</span> 
		<select id="bank_type">
		   <option  value="银行卡" >银行卡 </option>
		   <option value="支付宝" style="display:none;">支付宝</option>
		</select>
	</div>
	<div class="div-item">
		<span>支行信息</span> <input type="text" placeholder="请输入支行信息" id="branch_bank_name" />
	</div>
	<div class="div-item">
		<span>银行账号</span> <input type="text" placeholder="请输入银行账号" id="account_number" />
	</div>
	<input type="hidden" value="{$shop_id}" id="shop_id"/>
</form>
<button onclick="save()" class="btn-save">保存</button>
{/block} 
{block name="bottom"}{/block} 
{block name="javascript"}
<script type="text/javascript">
	
	function save(){
		var shop_id = $("#shop_id").val();
		var realname = $("#realname").val();
		var mobile = $("#mobile").val();
		var bank_type = $("#bank_type").val();
		var account_number = $("#account_number").val();
		var branch_bank_name = $("#branch_bank_name").val();
        if(realname==''){
        	showBox("姓名不能为空");
    		$("#realname").focus();
        	return false;
        }
        if(!(/^1[3|4|5|7|8][0-9]{9}$/.test(mobile))){
			showBox("手机号格式不正确");
    		$("#mobile").focus();
        	return false;
        }
        if(branch_bank_name==''){
        	showBox("支行信息不能为空");
    		$("#branch_bank_name").focus();
        	return false;
        }
        if(account_number==''){
        	showBox("银行账号不能为空");
    		$("#account_number").focus();
        	return false;
        }
      
		$.ajax({
			type : "post",
			url : "APP_MAIN/Member/addAccount",
			dataType : "json",
			data : {
				"realname":realname,
				"mobile":mobile,
				"bank_type":bank_type,
				"account_number":account_number,
				"branch_bank_name":branch_bank_name
			},
			success : function(data) {
				//alert(JSON.stringify(data));
				if(data['code']>1){
					showBox("添加成功");
					window.location.href = "APP_MAIN/member/accountList.html?shop_id="+shop_id;
				}else{
					showBox("添加失败");
				}
				
			}
		})
	}
</script>
{/block}
